﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>菜单管理</title>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
    <link href="../../../css/demo.css" rel="stylesheet" type="text/css" />
	<script src="../../../js/jquery/boot.js" type="text/javascript"></script>
</head>
<body>
    <h1>菜单管理</h1>      

    <div style="width:800px;">
        <div class="mini-toolbar" style="border-bottom:0;padding:0px;">
            <table style="width:100%;">
                <tr>
                    <td style="width:100%;">
                        <a class="mini-button" iconCls="icon-add" onclick="add()">增加</a>
                        <a class="mini-button" iconCls="icon-edit" onclick="edit()">编辑</a>
                        <a class="mini-button" iconCls="icon-remove" onclick="remove()">删除</a>       
                    </td>
                    <td style="white-space:nowrap;">
                        <input id="key" class="mini-textbox" emptyText="请输入菜单名" style="width:150px;" onenter="onKeyEnter"/>   
                        <a class="mini-button" onclick="search()">查询</a>
                    </td>
                </tr>
            </table>           
        </div>
    </div>
    <div id="datagrid1" class="mini-datagrid" style="width:800px;height:280px;" allowResize="true"
        url="../../../menu/list.jsps"  idField="id" multiSelect="true" 
    >
        <div property="columns">
            <!--<div type="indexcolumn"></div>        -->
            <div type="checkcolumn" ></div>        
            <div field="menuName" width="120" headerAlign="center" align="center" allowSort="false">菜单名称</div>    
            <div field="menuCode" width="120" headerAlign="center" align="center" allowSort="false">菜单编码</div>    
            <div field="menuUrl" width="120" headerAlign="center" align="left" allowSort="false">菜单链接</div>
            <div field="parentMenu.menuName" width="120" headerAlign="center" align="center" allowSort="false">父菜单</div>
            <div field="createTime" width="120" headerAlign="center" align="center" allowSort="true" dateFormat="yyyy-MM-dd HH:mm:ss">创建时间</div>
        </div>
    </div>
    

    <script type="text/javascript">
        mini.parse();

        var grid = mini.get("datagrid1");
        grid.load();
        grid.sortBy("parentMenu.menuname", "desc");

        
        function add() {
            
            mini.open({
                url: "./page/base/menu/menuWindow.html",
                title: "新增菜单", width: 600, height: 350,
                onload: function () {
                    var iframe = this.getIFrameEl();
                    var data = { action: "new"};
                    iframe.contentWindow.SetData(data);
                },
                ondestroy: function (action) {

                    grid.reload();
                }
            });
        }
        function edit() {
         
            var row = grid.getSelected();
            if (row) {
                mini.open({
                    url: "./page/base/menu/menuWindow.html",
                    title: "编辑菜单", width: 600, height: 350,
                    onload: function () {
                        var iframe = this.getIFrameEl();
                        var data = { action: "edit", id: row.id };
                        iframe.contentWindow.SetData(data);
                        
                    },
                    ondestroy: function (action) {
                        grid.reload();
                        
                    }
                });
                
            } else {
            	mini.alert("请选中一条记录");
            }
            
        }
        function remove() {
            
            var rows = grid.getSelecteds();
            if (rows.length > 0) {
                mini.confirm("确定删除选中记录？", "提示", function(action) {
                    if(action == "ok") {
	                    var ids = [];
	                    for (var i = 0, l = rows.length; i < l; i++) {
	                        var r = rows[i];
	                        ids.push(r.id);
	                    }
	                    var id = ids.join(',');
	                    grid.loading("操作中，请稍后......");
	                    $.ajax({
	                        url: "../../../menu/delete.jsps",
	                        data: {ids : id},
	                        success: function (text) {
	                        	if (text == "" || typeof(text) == 'object') {
	                            	grid.reload();
		                        } else {
		                        	var error = mini.decode(text);
		                    		mini.alert(error.error);
				                }
	                        },
	                        error: function () {
	                        }
	                    });
                    }
                });
            } else {
            	mini.alert("请选中一条记录");
            }
        }
        
        function search() {
            var key = mini.get("key").getValue();
            grid.load({ menuname: key });
        }
        
        function onKeyEnter(e) {
            search();
        }
    </script>
</body>
</html>